class PostsController < ApplicationController
    def create
        @post = Post.new(params[:post].permit(:title, :content))
        if @post.save
            Blog.find(params[:blog_id]).posts.push(@post) 
            User.find(session[:user_id]).posts.push(@post)
        end
        redirect_to blog_path(params[:blog_id])
    end
    
    def destroy
        @post = Post.find(params[:id])
        @post.destroy
        redirect_to blog_path(params[:blog_id])
    end
end
